/**
 * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.chrelyonly.config;

import cn.hutool.core.lang.Console;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.net.InetAddress;

/**
 * @author chrelyonly
 */
@Component
@Slf4j
public class AppInit implements CommandLineRunner {
    /**
     * 激活的环境
     */
    @Value("${spring.profiles.active}")
    private String profile;
    /**
     * 启动的端口
     */
    @Value("${server.port}")
    private String port;

    /**
     * 访问前缀
     */
    @Value("${server.servlet.context-path}")
    private String path;

    /**
     * 启动时打印信息
     */
    @Override
    public void run(String... args) throws Exception {
        Console.log(">>>>>>>>>>>>>>微信刷步系统<<<<<<<<<<<<<");
        String ip = InetAddress.getLocalHost().getHostAddress();
        Console.log(
                "    当前激活的环境：" + profile + "\n" +
                        "    端口：" + port + "\n" +
                        "    访问前缀：" + path + "\n" +
                        "    服务器IP：" + ip);
    }
//        Console.error(
//                "当前激活的环境：" + profile +
//                "- 本地访问地址: http://localhost:" + port + path + "\n\t" +
//                "- 网络访问地址: http://" + ip + ":" + port + path + "\n\t" +
//                "----------------------------------------------------------");
}

